package mailsystem.states;

import mailsystem.Connection;
import mailsystem.TelephoneResources;

public class RecordingStatus implements State {

	@Override
	public void runAction(Connection c, String key) {
		if (key.equals("#")) {
			if (c.getCurrentMailbox().checkPasscode(c.getAccumulatedKeys())) {				
				c.setState(Connection.MAILBOXMENU);
				c.showDisplayAllPhones(TelephoneResources.MAILBOX_MENU_TEXT);				
			} else
				c.speakAllPhones(TelephoneResources.INCORRECTPASSCODE);				
			c.setAccumulatedKeys("");
		} else
			c.setAccumulatedKeys(c.getAccumulatedKeys() + key);

	}

}
